cmake_minimum_required(VERSION 3.0.2)
project(autoware_ground_segmentation)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
  sensor_msgs
  geometry_msgs
  tf
  tf2
  tf2_ros
  tf2_eigen
  tf2_sensor_msgs
  pcl_ros
  pcl_conversions
)

find_package(PCL REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(Boost REQUIRED)

catkin_package(
  INCLUDE_DIRS include
  CATKIN_DEPENDS
    roscpp
    std_msgs
    sensor_msgs
    geometry_msgs
    tf
    tf2
    tf2_ros
    tf2_eigen
    tf2_sensor_msgs
    pcl_ros
    pcl_conversions
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${PCL_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
  ${EIGEN3_INCLUDE_DIRS}
  ${yaml-cpp_INCLUDE_DIRS}
  ${Boost_INCLUDE_DIRS}
)

# RANSAC Ground Filter
add_executable(ransac_ground_filter_node
  src/ransac_ground_filter/ransac_ground_filter_node.cpp
)

target_link_libraries(ransac_ground_filter_node
  ${catkin_LIBRARIES}
  ${PCL_LIBRARIES}
  ${OpenCV_LIBS}
  ${yaml-cpp_LIBRARIES}
  ${Boost_LIBRARIES}
)

# Ray Ground Filter
add_executable(ray_ground_filter_node
  src/ray_ground_filter/ray_ground_filter_node.cpp
  src/ray_ground_filter/gencolors.cpp
)

target_link_libraries(ray_ground_filter_node
  ${catkin_LIBRARIES}
  ${PCL_LIBRARIES}
  ${OpenCV_LIBS}
  ${yaml-cpp_LIBRARIES}
  ${Boost_LIBRARIES}
)

# Scan Ground Filter
add_executable(scan_ground_filter_node
  src/scan_ground_filter/scan_ground_filter_node.cpp
  src/scan_ground_filter/grid_ground_filter.cpp
)

target_link_libraries(scan_ground_filter_node
  ${catkin_LIBRARIES}
  ${PCL_LIBRARIES}
  ${OpenCV_LIBS}
  ${yaml-cpp_LIBRARIES}
  ${Boost_LIBRARIES}
)

# Install targets
install(TARGETS
  ransac_ground_filter_node
  ray_ground_filter_node
  scan_ground_filter_node
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

# Install launch files
install(DIRECTORY launch/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
  FILES_MATCHING PATTERN "*.launch"
)

# Install config files
install(DIRECTORY config/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/config
  FILES_MATCHING PATTERN "*.yaml"
) 